package com.da.javatest.leetCode2;

import java.util.Arrays;

public class Code628 {
    public int maximumProduct(int[] nums) {
        int l = nums.length - 1;
        Arrays.sort(nums);
        if (nums[0] > -1 || nums[l] < 0) {
            return nums[l] * nums[l - 1] * nums[l - 2];
        } else {
            return Math.max(nums[0] * nums[1], nums[l - 1] * nums[l - 2]) * nums[l];
        }
    }
}
